cmake_minimum_required(VERSION 3.0.0)

message(STATUS "Compiling Chip8QT!")

# 强制使用utf-8
# https://stackoverflow.com/questions/47690822/possible-to-force-cmake-msvc-to-use-utf-8-encoding-for-source-files-without-a-bo
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")

# 配置工程
set(projectName "Chip8QT")  # 工程名最好不要有空格和其它特殊符号
project(${projectName})
file(GLOB_RECURSE QT_UI_FILES "ui/*.ui") # 列出所有的ui文件
file(GLOB_RECURSE QT_QRC_FILES "resources/*.qrc") # 列出所有的qrc文件
set(QT_MODULES
	Core
	Gui        # QPixmap, QImage, etc.
	Widgets
	Multimedia # QSound
)
set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include_directories(./include ./src)
file(GLOB_RECURSE INC_FILES_PUBLIC "include/*.h" "include/*.hpp") # 列出所有头文件
file(GLOB_RECURSE INC_FILES_PRIVATE "src/*.h" "src/*.hpp") # 列出所有头文件
message(STATUS "INC_FILES_PRIVATE: "${INC_FILES_PRIVATE})
aux_source_directory(src SRC_FILES) # 列出所有源代码
source_group(ui FILES ${QT_UI_FILES})
source_group(resources FILES ${QT_QRC_FILES})

# chip8 库
include_directories(../chip8/interface)

# 配置Qt
find_package(Qt5 REQUIRED ${QT_MODULES})
qt5_wrap_ui(UI_WRAP ${QT_UI_FILES})
qt5_add_resources(QRC_WRAP ${QT_QRC_FILES})
add_executable(${projectName} ${SRC_FILES} ${INC_FILES_PUBLIC} ${INC_FILES_PRIVATE} ${UI_WRAP} ${QRC_WRAP}) # 输出exe
qt5_use_modules(${projectName} ${QT_MODULES})

